(function(){
	var items = document.getElementsByClassName("item");
	var next = document.getElementById("next");
	var prev = document.getElementById("prev");
	var num = 0;
	for(var i = 0;i < items.length;i++){
		var item = items[i];
		item.style["left"] = item.offsetWidth*i+"px";
		item.style["transitionDelay"] = i*0.2+"s";
		var child = item.children;
		for(var j = 0;j < child.length;j++){
			var img = child[j];
			img.style["backgroundPositionX"] = -i*item.offsetWidth+"px";
		}
	};
	function animation(reg){
		var rotate = reg*90;
		for(i = 0;i<items.length;i++){
			items[i].style["transform"] = "rotateX(" + rotate + "deg)";
			console.log(items[i].style["transform"])
		}
	}
	next.onclick = function(){
		num++;
		animation(num);
	}
	prev.onclick = function(){
		num--;
		animation(num);
	}
	var timer = setInterval(function(){
		next.onclick();
	},4000);
})();
